-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EIP-7549: validator client #14158
EIP-7549: validator client #14158
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions, overall looks good though
versionAtts := make([]ethpb.Att, 0, len(atts)) | ||
if postElectra { | ||
for _, a := range atts { | ||
if a.Version() == version.Electra { | ||
versionAtts = append(versionAtts, a) | ||
} | ||
} | ||
} else { | ||
for _, a := range atts { | ||
if a.Version() == version.Phase0 { | ||
versionAtts = append(versionAtts, a) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests for this function logic? If it's too complicated, consider moving this filtering logic to its own method and testing that.
if len(a) == 0 { | ||
return a | ||
} | ||
|
||
var limit uint64 | ||
if a[0].Version() == version.Phase0 { | ||
limit = params.BeaconConfig().MaxAttestations | ||
} else { | ||
limit = params.BeaconConfig().MaxAttestationsElectra | ||
} | ||
if uint64(len(a)) > limit { | ||
return a[:limit] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be tested?
}, | ||
}) | ||
go func() { | ||
ctx = trace.NewContext(context.Background(), trace.FromContext(ctx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this line?
ctx = trace.NewContext(context.Background(), trace.FromContext(ctx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, but it was there previously. I am a little scared to change this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's safe to delete it.
What this line of code does is "create a new context, which does not inherit any deadline from the parent, but includes all of the trace/span metadata from the parent context".
However, this isn't even used... so let's delete it
Data: data, | ||
AggregationBits: aggregationBitfield, | ||
Signature: sig, | ||
// TODO: Extend to Electra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is slasher logic which hasn't been updated to Electra yet. It is non-trivial and needs more discussion.
validator/client/attest.go
Outdated
if postElectra { | ||
span.AddAttributes( | ||
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing. | ||
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)), | ||
trace.StringAttribute("committeeBitfield", fmt.Sprintf("%#x", committeeBits)), | ||
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)), | ||
trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)), | ||
trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)), | ||
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)), | ||
) | ||
} else { | ||
span.AddAttributes( | ||
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing. | ||
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)), | ||
trace.Int64Attribute("committeeIndex", int64(data.CommitteeIndex)), | ||
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)), | ||
trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)), | ||
trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)), | ||
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)), | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if postElectra { | |
span.AddAttributes( | |
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing. | |
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)), | |
trace.StringAttribute("committeeBitfield", fmt.Sprintf("%#x", committeeBits)), | |
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)), | |
trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)), | |
trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)), | |
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)), | |
) | |
} else { | |
span.AddAttributes( | |
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing. | |
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)), | |
trace.Int64Attribute("committeeIndex", int64(data.CommitteeIndex)), | |
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)), | |
trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)), | |
trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)), | |
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)), | |
) | |
} | |
span.AddAttributes( | |
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing. | |
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)), | |
trace.StringAttribute("committeeBitfield", fmt.Sprintf("%#x", committeeBits)), | |
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)), | |
trace.Int64Attribute("justifiedEpoch", int64(data.Source.Epoch)), | |
trace.Int64Attribute("targetEpoch", int64(data.Target.Epoch)), | |
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)), | |
) | |
if postElectra { | |
span.AddAttributes( | |
trace.StringAttribute("committeeBitfield", fmt.Sprintf("%#x", committeeBits)), | |
) | |
} else { | |
span.AddAttributes( | |
trace.Int64Attribute("committeeIndex", int64(data.CommitteeIndex)), | |
) | |
} |
This reverts commit f59e1459f3f7561e0483bc8542110794951585c5.
|
||
root, err := att.GetData().HashTreeRoot() | ||
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "Could not tree hash attestation: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, status.Errorf(codes.Internal, "Could not tree hash attestation: %v", err) | |
return nil, status.Errorf(codes.Internal, "Could not get attestation hash tree: %v", err) |
if err != nil { | ||
continue | ||
return nil, errors.Wrap(err, "failed to create attestation ID") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping errors the same
return nil, errors.Wrap(err, "failed to create attestation ID") | |
return nil, errors.Wrap(err, "could not create attestation ID") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Please address @saolyn comments in a follow up PR
What type of PR is this?
Feature
What does this PR do? Why is it needed?
Implements the following changes for EIP-7549
ProposeAttestationElectra